import * as mongoose from 'mongoose';
import {composeWithMongoose, convertModelToGraphQL} from 'graphql-compose-mongoose';
import {TypeComposer} from 'graphql-compose';

export function convertFromMongoModel(model: mongoose.Model, name: string): TypeComposer<any> {
  const tc = convertModelToGraphQL(model, name);
  delete model.schema._gqcTypeComposer;
  return tc;
}

export function composeFromMongoModel(model: mongoose.Model, opts: any): TypeComposer<any> {
  const tc = composeWithMongoose(model, opts);
  delete model.schema._gqcTypeComposer;
  return tc;
}
